#lang racket


(require "../point.rkt")

(require "domain.rkt"
         "parametric-curve.rkt"
         "segment.rkt")


(provide (struct-out straight-line))


(define-struct (straight-line parametric-curve)
  (start end)
  #:constructor-name new-straight-line)


(define (straight-line-object start end)
  (λ (t)
    (p+p
     (p*n start (- 1 t))
     (p*n end t))))

(define (straight-line-tangent start end)
  (λ (t)
    (unit (p-p end start))))

(define (straight-line-normal start end)
  (λ (t)
    (raise (make-unsupported
            "The normal is not defined for a straight line"
            (current-continuation-marks)))))

(define (straight-line-binormal start end)
  (λ (t)
    (raise (make-unsupported
            "The binormal is not defined for a straight line"
            (current-continuation-marks)))))

(define (make-straight-line transformation start end)
  (new-straight-line
   (make-domain 'closed 0 'closed 1)
   (straight-line-object start end)
   (straight-line-tangent start end)
   (straight-line-normal start end)
   (straight-line-binormal start end)
   transformation
   start))